/*
Copyright 2009 Lawren Quigley-Jones

   trade-assistant.js is part of Preopoly.

   Preopoly is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   Preopoly is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with Preopoly.  If not, see <http://www.gnu.org/licenses/>.

   Contact Lawren Quigley-Jones with questions or bugs:
   lawrenqj@gmail.com
*/

function WelcomeAssistant() {
	/* this is the creator function for your scene assistant object. It will be passed all the 
	   additional parameters (after the scene name) that were passed to pushScene. The reference
	   to the scene controller (this.controller) has not be established yet, so any initialization
	   that needs the scene controller should be done in the setup function below. */
}

WelcomeAssistant.prototype.setup = function() {

	var myMenuAttr = {omitDefaultItems: true};
	var myMenuModel = {
	  visible: true,
	  items: [
            { label: "About Preopoly...", command: 'do-about' },
	    { label: "Preferences", command: 'do-prefs' },
	    { label: "Assets", command: 'do-assets' },
	    { label: "Help", command: 'do-help' }
	  ]
	};

		//  Setup App Menu
	this.controller.setupWidget(Mojo.Menu.appMenu, myMenuAttr, myMenuModel);

		// continue game button
        this.controller.setupWidget('MyButton',{},
        this.buttonModel1 = {
                buttonLabel : 'Continue Game',
                buttonClass : '',
                disable : false
        });
        Mojo.Event.listen(this.controller.get('MyButton'), Mojo.Event.tap, this.continueGame.bind(this));

		// new game button
        this.controller.setupWidget('NewGameButton',{},
        this.newGameButtonModel = {
                buttonLabel : 'New Game',
                buttonClass : '',
                disable : false
        });
        Mojo.Event.listen(this.controller.get('NewGameButton'), Mojo.Event.tap, this.newGame.bind(this));

		// preferences button
        this.controller.setupWidget('PreferencesButton',{},
        this.preferencesButtonModel = {
                buttonLabel : 'Preferences',
                buttonClass : '',
                disable : false
        });
        Mojo.Event.listen(this.controller.get('PreferencesButton'), Mojo.Event.tap, this.loadPreferences.bind(this));
}

WelcomeAssistant.prototype.continueGame = function(event){
	this.firstValue = this.buttonModel1.original;  
	this.controller.stageController.pushScene('board',this.firstValue);        
}

WelcomeAssistant.prototype.newGame  = function(event){
	clearDynamicObjects();
	this.newgame = this.newGameButtonModel.original;  
	this.controller.stageController.pushScene('board',this.newgame);
}

WelcomeAssistant.prototype.loadPreferences  = function(event){
	this.prefs = this.preferencesButtonModel.original;  
	this.controller.stageController.pushScene('preferences',this.prefs);
}

WelcomeAssistant.prototype.activate = function(event) {
	/* put in event handlers here that should only be in effect when this scene is active. For
	   example, key handlers that are observing the document */
}


WelcomeAssistant.prototype.deactivate = function(event) {
	/* remove any event handlers you added in activate and do any other cleanup that should happen before
	   this scene is popped or another scene is pushed on top */
}

WelcomeAssistant.prototype.cleanup = function(event) {
	/* this function should do any cleanup needed before the scene is destroyed as 
	   a result of being popped off the scene stack */
	Mojo.Event.stopListening(this.controller.get('MyButton'),Mojo.Event.tap, this.continueGame.bind(this));
        Mojo.Event.stopListening(this.controller.get('NewGameButton'), Mojo.Event.tap, this.newGame.bind(this));
        Mojo.Event.stopListening(this.controller.get('PreferencesButton'), Mojo.Event.tap, this.loadPreferences.bind(this));
}
